<?php

/**
 * Conexão com o banco de dados.
 *
 * @author Kelvin Pereira Alves <kelvinpalves@gmail.com>
 */
class Connect {
    //Porta padrão mysql 3336
    private $connect;
    
    //Dados de Produção
    private $userName;
    private $password;
    private $host;
    private $dbName;
    //Dados de Homologação
    private $userNameRatification = "root";
    private $passwordRatification = "78981_";
    private $hostRatification = "localhost";
    private $dbNameRatification = "db_realty";
    
    function __construct() {
        try{
            if(isset($_SESSION["connect"])){
                $this->connect = unserialize($_SESSION["connect"]);
            }else{
                //Conexão produção
                //$this->connect = new PDO('mysql:host=' . $this->host . ';dbname=' . $this->dbName, $this->userName, $this->password);
                //Conexão homologação
                $this->connect = new PDO('mysql:host=' . $this->hostRatification . ';dbname=' . $this->dbNameRatification, $this->userNameRatification, $this->passwordRatification);
                $this->connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                $_SESSION["connect"] = serialize($this->conn);
            }
        } catch (Exception $ex) {
        }
    }
    
    function getConnect() {
        return $this->connect;
    }

    function setConnect($connect) {
        $this->connect = $connect;
    }
}
